package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    //今日注册或者登陆人数
    @Select("select count(distinct user_id) from tb_log where log_time = #{today} and type = #{type}")
    Integer findRegisterOrLoginCount(@Param("today") String today,@Param("type") String type);

    //今日活跃人数
    @Select("select count(distinct user_id) from tb_log where log_time = #{today}")
    Integer findActiveCount(@Param("today") String today);

    //次日留存人数
    @Select("select count(distinct user_id) from tb_log where log_time = #{today} and user_id in " +
            "(select distinct user_id from tb_log where log_time = #{yesterday} and type = '0102')")
    Integer findRetention1dCount(@Param("today") String today,@Param("yesterday") String yesterday);

}